import java.util.Scanner;

/**
 * @author  yangjingdou
 */
public class ShapeAreaCalculator {
    private static final String SQUARE = "正⽅形";
    private static final String CIRCLE = "圆形";
    private static final String TRIANGLE = "三⻆形";
    private static final String TRAPEZOID = "梯形";
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

                String shape = scanner.nextLine().trim().toLowerCase();
        if (SQUARE.equals(shape)) {
            calculateSquareArea(scanner);
        } else if (CIRCLE.equals(shape)) {
            calculateCircleArea(scanner);
        } else if (TRIANGLE.equals(shape)) {
            calculateTriangleArea(scanner);
        } else if (TRAPEZOID.equals(shape)) {
            calculateTrapezoidArea(scanner);
        } else {
            System.out.println(" 不⽀持的形状类型。 ");
        }
        scanner.close();
    }


    // 计算正方形面积的方法
    /**
     *
     计算正⽅形⾯积的⽅法* @param scanner
     ⽤于接收⽤户输⼊的
     Scanner
     对象*/
    public static void calculateSquareArea(Scanner scanner) {
        System.out.println(" 请输⼊正⽅形的边⻓： ");
        double side = scanner.nextDouble();
        System.out.println(" 正⽅形的⾯积是： " + squareArea(side));
    }
    /**
     *
     计算圆形⾯积的⽅法* @param scanner
     ⽤于接收⽤户输⼊的
     Scanner
     对象*/
    public static void calculateCircleArea(Scanner scanner) {
        System.out.println(" 请输⼊圆形的半径： ");
        double radius = scanner.nextDouble();
        System.out.println(" 圆形的⾯积是： " + circleArea(radius));
    }
    /**
     *
     计算三⻆形⾯积的⽅法* @param scanner
     ⽤于接收⽤户输⼊的
     Scanner
     对象*/
    public static void calculateTriangleArea(Scanner scanner) {
        System.out.println(" 请输⼊三⻆形的三条边⻓： ");
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double c = scanner.nextDouble();
        System.out.println(" 三⻆形的⾯积是： " + triangleArea(a, b, c));
    }
    /**
     *
     计算梯形⾯积的⽅法
     * @param scanner
    ⽤于接收⽤户输⼊的
    Scanner
    对象
     */
    public static void calculateTrapezoidArea(Scanner scanner) {
        System.out.println(" 请输⼊梯形的上底⻓度： ");
        double base1 = scanner.nextDouble();
        System.out.println(" 请输⼊梯形的下底⻓度： ");
        double base2 = scanner.nextDouble();
        System.out.println(" 请输⼊梯形的⾼： ");
        double height = scanner.nextDouble();
        System.out.println(" 梯形的⾯积是： " + trapezoidArea(base1, base2, height));
    }
    /**
     *
     计算正⽅形⾯积的静态⽅法
     * @param side
    正⽅形的边⻓
     * @return
    返回正⽅形的⾯积
     */
    public static double squareArea(double side) {
        return side * side;
    }
    /**
     *
     计算圆形⾯积的静态⽅法
     * @param radius
    圆形的半径
     * @return
    返回圆形的⾯积
     */
    public static double circleArea(double radius) {
        return Math.PI * radius * radius;
    }
    /**
     *
     计算三⻆形⾯积的静态⽅法（使⽤海伦公式）
     * @param a
    三⻆形的第⼀条边⻓
     * @param b
    三⻆形的第⼆条边⻓
     * @param c
    三⻆形的第三条边⻓
     * @return
    返回三⻆形的⾯积
     */
    public static double triangleArea(double a, double b, double c) {
        double s = (a + b + c) / 2;
        return Math.sqrt(s * (s - a) * (s - b) * (s - c));
    }
    /**
     *
     计算梯形⾯积的静态⽅法
     * @param base1
    梯形的上底⻓度
     * @param base2
    梯形的下底⻓度
     * @param height
    梯形的⾼
     * @return
    返回梯形的⾯积
     */
    public static double trapezoidArea(double base1, double base2, double
            height) {
        return (base1 + base2) * height / 2;
    }

}
